home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / game / role / ScottItal.lha / ScottItal / Src / SCOTT.c < prev    next >
C/C++ Source or Header  |  2002-11-01  |  28KB  |  904 lines

  1. #include <pragma/all_lib.h>
  2.  
  3. #include "SCOTT_A.c"
  4. void choice(void)
  5. {
  6.     BYTE key;
  7.  
  8.     put_choice();
  9.     while (1) {
  10.         key = KeyInput();
  11.         //printf("Key: %c\n",key);
  12.         if (tolower(key) == 'f') {
  13.             close_all();
  14.             exit(0);
  15.         }
  16.         if (tolower(key) == 'r') {
  17.             cursor(FALSE);
  18.             WriteCON("Ricarica\n");
  19.             Speak("Ricarica");
  20.             OutReset();
  21.             if (RestoreGame() == FALSE) {
  22.                 Look();
  23.                 break;
  24.             }
  25.             else put_choice();
  26.         }
  27.         if ((tolower(key) == 'c') && RESTART) {
  28.             cursor(FALSE);
  29.             WriteCON("Ricomincia\n");
  30.             Speak("Ricomincia");
  31.             OutReset();
  32.             if ((LoadRestart() == FALSE) && RESTART) {
  33.                 Restart();
  34.                 break;
  35.             }
  36.             else put_choice();
  37.         }
  38.     }
  39. }
  40.  
  41. void SaveBody(FILE *f)
  42. {
  43.     int ct;
  44.  
  45.     for(ct=0;ct<16;ct++)
  46.     {
  47.         fprintf(f,"%d %d\n",Counters[ct],RoomSaved[ct]);
  48.     }
  49.     fprintf(f,"%ld %d %hd %d %d %hd\n",BitFlags, (BitFlags&(1L<<DARKBIT))?1:0,
  50.         MyLoc,CurrentCounter,SavedRoom,GameHeader.LightTime);
  51.     for(ct=0;ct<=GameHeader.NumItems;ct++)
  52.         fprintf(f,"%hd\n",(short)Items[ct].Location);
  53.     fclose(f);
  54. }
  55.  
  56. void LoadBody(FILE *f)
  57. {
  58.     int ct;
  59.     short lo;
  60.     short DarkFlag;
  61.  
  62.     for(ct=0;ct<16;ct++)
  63.     {
  64.         fscanf(f,"%d %d\n",&Counters[ct],&RoomSaved[ct]);
  65.     }
  66.     fscanf(f,"%ld %d %hd %d %d %hd\n",
  67.         &BitFlags,&DarkFlag,&MyLoc,&CurrentCounter,&SavedRoom,
  68.         &GameHeader.LightTime);
  69.     /* Backward compatibility */
  70.     if(DarkFlag)
  71.         BitFlags|=(1L<<15);
  72.     for(ct=0;ct<=GameHeader.NumItems;ct++)
  73.     {
  74.         fscanf(f,"%hd\n",&lo);
  75.         Items[ct].Location=(unsigned char)lo;
  76.     }
  77.     fclose(f);
  78. }
  79.  
  80. BOOL SaveRestart()
  81. {
  82.     FILE *f;
  83.  
  84.     f = fopen(restart_file,"w");
  85.     if (f==NULL) return(TRUE);
  86.     SaveBody(f);
  87.     //SetProtection(restart_file,128);
  88.     restart_lock = Lock(restart_file,SHARED_LOCK);
  89.     return(FALSE);
  90. }
  91.  
  92. BOOL LoadRestart()
  93. {
  94.     FILE *f=
  95.  
  96.     f = fopen(restart_file,"r");
  97.     if (f==NULL) return(TRUE);
  98.     LoadBody(f);
  99.     return(FALSE);
  100. }
  101.  
  102. int PerformLine(int ct)
  103. {
  104.     int continuation=0;
  105.     int param[5],pptr=0;
  106.     int act[4];
  107.     int cc=0;
  108.  
  109.     while(cc<5)
  110.     {
  111.         int cv,dv;
  112.         cv=Actions[ct].Condition[cc];
  113.         dv=cv/20;
  114.         cv=cv%20;
  115.         //cv%=20;
  116.         switch(cv)
  117.         {
  118.             case 0:
  119.                 param[pptr++]=dv;
  120.                 break;
  121.             case 1://si ha l'oggetto
  122.                 if(Items[dv].Location!=CARRIED)
  123.                     return(0);
  124.                 break;
  125.             case 2:
  126.                 if(Items[dv].Location!=MyLoc)
  127.                     return(0);
  128.                 break;
  129.             case 3:
  130.                 if(Items[dv].Location!=CARRIED&&
  131.                     Items[dv].Location!=MyLoc)
  132.                     return(0);
  133.                 break;
  134.             case 4:// si identifica dv come stanza
  135.                 if(MyLoc!=dv)
  136.                     return(0);
  137.                 break;
  138.             case 5:
  139.                 if(Items[dv].Location==MyLoc)
  140.                     return(0);
  141.                 break;
  142.             case 6:
  143.                 if(Items[dv].Location==CARRIED)
  144.                     return(0);
  145.                 break;
  146.             case 7:
  147.                 if(MyLoc==dv)
  148.                     return(0);
  149.                 break;
  150.             case 8:
  151.                 if((BitFlags&(1L<<dv))==0)
  152.                     return(0);
  153.                 break;
  154.             case 9:
  155.                 if(BitFlags&(1L<<dv))
  156.                     return(0);
  157.                 break;
  158.             case 10:
  159.                 if(CountCarried()==0)
  160.                     return(0);
  161.                 break;
  162.             case 11:
  163.                 if(CountCarried())
  164.                     return(0);
  165.                 break;
  166.             case 12:
  167.                 if(Items[dv].Location==CARRIED||Items[dv].Location==MyLoc)
  168.                     return(0);
  169.                 break;
  170.             case 13:
  171.                 if(Items[dv].Location==0)
  172.                     return(0);
  173.                 break;
  174.             case 14:
  175.                 if(Items[dv].Location)
  176.                     return(0);
  177.                 break;
  178.             case 15:
  179.                 if(CurrentCounter>dv)
  180.                     return(0);
  181.                 break;
  182.             case 16:
  183.                 if(CurrentCounter<=dv)
  184.                     return(0);
  185.                 break;
  186.             case 17:
  187.                 if(Items[dv].Location!=Items[dv].InitialLoc)
  188.                     return(0);
  189.                 break;
  190.             case 18:
  191.                 if(Items[dv].Location==Items[dv].InitialLoc)
  192.                     return(0);
  193.                 break;
  194.             case 19: /* Only seen in Brian Howarth games so far */
  195.                 if(CurrentCounter!=dv)
  196.                     return(0);
  197.                 break;
  198.         }
  199.         cc++;
  200.     }
  201.     /* Actions */
  202.     act[0]=Actions[ct].Action[0];
  203.     act[2]=Actions[ct].Action[1];
  204.     act[1]=act[0]%150;
  205.     act[3]=act[2]%150;
  206.     act[0]/=150;
  207.     act[2]/=150;
  208.     cc=0;
  209.     pptr=0;
  210.     while(cc<4)
  211.     {
  212.         //printf("Action: %d\n",act[cc]);
  213.         if(act[cc]>=1 && act[cc]<52)
  214.         {
  215.             OutputScott(Messages[act[cc]]);
  216.             Speak(Messages[act[cc]]);
  217.             OutputScott("\n");
  218.         }
  219.         else if(act[cc]>101)
  220.         {
  221.             OutputScott(Messages[act[cc]-50]);
  222.             Speak(Messages[act[cc]-50]);
  223.             OutputScott("\n");
  224.         }
  225.         else switch(act[cc])
  226.         {
  227.             case 0: /* NOP */
  228.                 break;
  229.             case 52:
  230.                 if(CountCarried()==GameHeader.MaxCarry)
  231.                 {
  232.                     if(Options&YOUARE) {
  233.                         OutputScott("Sei troppo carico.\n");
  234.                         Speak("Sei troppo carico.");
  235.                     }
  236.                     else {
  237.                         OutputScott("Sono troppo carico !\n");
  238.                         Speak("Sono troppo carico !");
  239.                     }
  240.                     break;
  241.                 }
  242.                 if(Items[param[pptr]].Location==MyLoc)
  243.                     Redraw=1;
  244.                 Items[param[pptr++]].Location= CARRIED;
  245.                 break;
  246.             case 53:
  247.                 Redraw=1;
  248.                 Items[param[pptr++]].Location=MyLoc;
  249.                 break;
  250.             case 54:
  251.                 Redraw=1;
  252.                 MyLoc=param[pptr++];
  253.                 break;
  254.             case 55:
  255.                 if(Items[param[pptr]].Location==MyLoc)
  256.                     Redraw=1;
  257.                 Items[param[pptr++]].Location=0;
  258.                 break;
  259.             case 56:
  260.                 BitFlags|=1L<<DARKBIT;
  261.                 break;
  262.             case 57:
  263.                 BitFlags&=~(1L<<DARKBIT);
  264.                 break;
  265.             case 58:
  266.                 BitFlags|=(1L<<param[pptr++]);
  267.                 break;
  268.             case 59:
  269.                 if(Items[param[pptr]].Location==MyLoc)
  270.                     Redraw=1;
  271.                 Items[param[pptr++]].Location=0;
  272.                 break;
  273.             case 60:
  274.                 BitFlags&=~(1L<<param[pptr++]);
  275.                 break;
  276.             case 61:
  277.                 if(Options&YOUARE) {
  278.                     OutputScott("Sei morto.\n");
  279.                     Speak("Sei morto");
  280.                 }
  281.                 else {
  282.                     OutputScott("Sono morto.\n");
  283.                     Speak("Sono morto");
  284.                 }
  285.                 BitFlags&=~(1L<<DARKBIT);
  286.                 MyLoc=GameHeader.NumRooms; /* It seems to be what the code says! */
  287.                 Look();
  288.                 break;
  289.             case 62:
  290.             {
  291.                 /* Bug fix for some systems - before it could get parameters wrong */
  292.                 int i=param[pptr++];
  293.                 Items[i].Location=param[pptr++];
  294.                 Redraw=1;
  295.                 break;
  296.             }
  297.             case 63:
  298. doneit:         OutBuf("Il gioco e' finito!\n");
  299.                 Speak("Il gioco e' finito");
  300.                 choice();
  301.                 break;
  302.             case 64:
  303.                 Look();
  304.                 break;
  305.             case 65:
  306.             {
  307.                 int ct=0;
  308.                 int n=0;
  309.                 while(ct<=GameHeader.NumItems)
  310.                 {
  311.                     if(Items[ct].Location==GameHeader.TreasureRoom &&
  312.                       *Items[ct].Text=='*')
  313.                         n++;
  314.                     ct++;
  315.                 }
  316.                 if(Options&YOUARE) {
  317.                     OutputScott("Hai accumulato ");
  318.                     Speak("Hai accumulato");
  319.                 }
  320.                 else {
  321.                     OutputScott("Ho accumulato ");
  322.                     Speak("Ho accumulato");
  323.                 }
  324.                 OutputNumber(n);
  325.                 SpeakNum(n);
  326.                 OutputScott("tesori.\nSu una scala da 0 a 100, il tuo punteggio e' ");
  327.                 Speak("tesori.\nSu una scala da 0 a 100, il tuo punteggio e' ");
  328.                 OutputNumber((n*100)/GameHeader.Treasures);
  329.                 SpeakNum((n*100)/GameHeader.Treasures);
  330.                 OutputScott("punti.\n");
  331.                 Speak("punti");
  332.                 if(n==GameHeader.Treasures)
  333.                 {
  334.                     OutputScott("Ben fatto.\n");
  335.                     Speak("Ben fatto");
  336.                     goto doneit;
  337.                 }
  338.                 break;
  339.             }
  340.             case 66:
  341.             {
  342.                 int ct=0;
  343.                 int f=0;
  344.                 if(Options&YOUARE) {
  345.                     OutputScott("Hai con te:\n");
  346.                     Speak("Hai con te:");
  347.                 }
  348.                 else {
  349.                     OutputScott("Ho con me:\n");
  350.                     Speak("Ho con me:");
  351.                 }
  352.                 while(ct<=GameHeader.NumItems)
  353.                 {
  354.                     if(Items[ct].Location==CARRIED)
  355.                     {
  356.                         if(f==1)
  357.                         {
  358.                             if (Options & TRS80_STYLE)
  359.                                 OutputScott(". ");
  360.                             else
  361.                                 OutputScott(" - ");
  362.                         }
  363.                         f=1;
  364.                         OutputScott(Items[ct].Text);
  365.                         Speak(Items[ct].Text);
  366.                     }
  367.                     ct++;
  368.                 }
  369.                 if(f==0) {
  370.                     OutputScott("Niente");
  371.                     Speak("Niente");
  372.                 }
  373.                 OutputScott(".\n");
  374.                 break;
  375.             }
  376.             case 67:
  377.                 BitFlags|=(1L<<0);
  378.                 break;
  379.             case 68:
  380.                 BitFlags&=~(1L<<0);
  381.                 break;
  382.             case 69:
  383.                 GameHeader.LightTime=LightRefill;
  384.                 if(Items[LIGHT_SOURCE].Location==MyLoc)
  385.                     Redraw=1;
  386.                 Items[LIGHT_SOURCE].Location=CARRIED;
  387.                 BitFlags&=~(1L<<LIGHTOUTBIT);
  388.                 break;
  389.             case 70:
  390.                 clrscr(); /* pdd. */
  391.                 OutReset();
  392.                 break;
  393.             case 71:
  394.                 SaveGame();
  395.                 break;
  396.             case 72:
  397.             {
  398.                 int i1=param[pptr++];
  399.                 int i2=param[pptr++];
  400.                 int t=Items[i1].Location;
  401.                 if(t==MyLoc || Items[i2].Location==MyLoc)
  402.                     Redraw=1;
  403.                 Items[i1].Location=Items[i2].Location;
  404.                 Items[i2].Location=t;
  405.                 break;
  406.             }
  407.             case 73:
  408.                 continuation=1;
  409.                 break;
  410.             case 74:
  411.                 if(Items[param[pptr]].Location==MyLoc)
  412.                     Redraw=1;
  413.                 Items[param[pptr++]].Location= CARRIED;
  414.                 break;
  415.             case 75:
  416.             {
  417.                 int i1,i2;
  418.                 i1=param[pptr++];
  419.                 i2=param[pptr++];
  420.                 if(Items[i1].Location==MyLoc)
  421.                     Redraw=1;
  422.                 Items[i1].Location=Items[i2].Location;
  423.                 if(Items[i2].Location==MyLoc)
  424.                     Redraw=1;
  425.                 break;
  426.             }
  427.             case 76:    /* Looking at adventure .. */
  428.                 Look();
  429.                 break;
  430.             case 77:
  431.                 if(CurrentCounter>=0)
  432.                     CurrentCounter--;
  433.                 break;
  434.             case 78:
  435.                 OutputNumber(CurrentCounter);
  436.                 SpeakNum(CurrentCounter);
  437.                 break;
  438.             case 79:
  439.                 CurrentCounter=param[pptr++];
  440.                 break;
  441.             case 80:
  442.             {
  443.                 int t=MyLoc;
  444.                 MyLoc=SavedRoom;
  445.                 SavedRoom=t;
  446.                 Redraw=1;
  447.                 break;
  448.             }
  449.             case 81:
  450.             {
  451.                 /* This is somewhat guessed. Claymorgue always
  452.                    seems to do select counter n, thing, select counter n,
  453.                    but uses one value that always seems to exist. Trying
  454.                    a few options I found this gave sane results on ageing */
  455.                 int t=param[pptr++];
  456.                 int c1=CurrentCounter;
  457.                 CurrentCounter=Counters[t];
  458.                 Counters[t]=c1;
  459.                 break;
  460.             }
  461.             case 82:
  462.                 CurrentCounter+=param[pptr++];
  463.                 break;
  464.             case 83:
  465.                 CurrentCounter-=param[pptr++];
  466.                 if(CurrentCounter< -1)
  467.                     CurrentCounter= -1;
  468.                 /* Note: This seems to be needed. I don't yet
  469.                    know if there is a maximum value to limit too */
  470.                 break;
  471.             case 84:
  472.                 OutputScott(NounText);
  473.                 break;
  474.             case 85:
  475.                 OutputScott(NounText);
  476.                 OutputScott("\n");
  477.                 break;
  478.             case 86:
  479.                 OutputScott("\n");
  480.                 break;
  481.             case 87:
  482.             {
  483.                 /* Changed this to swap location<->roomflag[x]
  484.                    not roomflag 0 and x */
  485.                 int p=param[pptr++];
  486.                 int sr=MyLoc;
  487.                 MyLoc=RoomSaved[p];
  488.                 RoomSaved[p]=sr;
  489.                 Redraw=1;
  490.                 break;
  491.             }
  492.             case 88:
  493.                 Delay(100); /* DOC's say 2 seconds. Spectrum times at 1.5 */
  494.                 break;
  495.             case 89:
  496.                 //printf("A89->Param: %d\n",param[pptr]);
  497.                 if (GFX) {
  498.                     if (Handle_Pic(nroom + param[pptr++])) {
  499.                         WriteCON("\n <Premi Return>\n");
  500.                         while (KeyInput() != 13) ;
  501.                         Handle_Pic(MyLoc);
  502.                     }
  503.                 }
  504.                 else pptr++;
  505.                 /* SAGA draw picture n */
  506.                 /* Spectrum Seas of Blood - start combat ? */
  507.                 /* Poking this into older spectrum games causes a crash */
  508.                 break;
  509.             default:
  510.                 fprintf(stderr,"Sconosciuta azione %d [Parametro comincia %d %d]\n",
  511.                     act[cc],param[pptr],param[pptr+1]);
  512.                 break;
  513.         }
  514.         cc++;
  515.     }
  516.     return(1+continuation);
  517. }
  518.  
  519.  
  520. int PerformActions(int vb,int no)
  521. {
  522.     static int disable_sysfunc=0;   /* Recursion lock */
  523.     int d=BitFlags&(1L<<DARKBIT);
  524.  
  525.     int ct=0;
  526.     int fl;
  527.     int doagain=0;
  528.     if(vb==1 && no == -1 )
  529.     {//vb=1 indica 'go'
  530.         OutputScott("Dai anche una direzione.\n");
  531.         Speak("Dai anche una direzione.");
  532.         return(0);
  533.     }
  534.     if(vb==1 && no>=1 && no<=6)
  535.     {
  536.         int nl;
  537.         if(Items[LIGHT_SOURCE].Location==MyLoc ||
  538.            Items[LIGHT_SOURCE].Location==CARRIED)
  539.             d=0;//se ho la luce accesa o e' accesa nella stanza posso vedere
  540.         if(d) {
  541.             OutputScott("E' pericoloso muoversi nel buio!\n");
  542.             Speak("E' pericoloso muoversi nel buio!");
  543.         }
  544.         nl=Rooms[MyLoc].Exits[no-1];
  545.         if(nl!=0)//il valore 0 indica un'uscita non valida
  546.         {
  547.             MyLoc=nl;
  548.             OutputScott("O.K.\n");
  549.             Speak("O.K.");
  550.             Look();
  551.             return(0);
  552.         }
  553.         if(d)// se mi muovo nel buio e vado verso un'uscita non valida muoio
  554.         {
  555.             if (Options&YOUARE) {
  556.                 OutputScott("Scivoli e ti rompi il collo.\n");
  557.                 Speak("Scivoli e ti rompi il collo.");
  558.             }
  559.             else {
  560.                 OutputScott("Scivolo e mi rompo il collo.\n");
  561.                 Speak("Scivolo e mi rompo il collo.");
  562.             }
  563.             choice();
  564.         }
  565.         if(Options&YOUARE) {//mi muovo verso un'uscita non valida
  566.             OutputScott("Non puoi andare in quella direzione.\n");
  567.             Speak("Non puoi andare in quella direzione.");
  568.         }
  569.         else {
  570.             OutputScott("Non posso andare in quella direzione.\n");
  571.             Speak("Non posso andare in quella direzione.");
  572.         }
  573.         return(0);
  574.     }
  575.     fl= -1;
  576.     while(ct<=GameHeader.NumActions)
  577.     {
  578.         int vv,nv;
  579.         vv=Actions[ct].Vocab;
  580.         /* Think this is now right. If a line we run has an action73
  581.            run all following lines with vocab of 0,0 */
  582.         if(vb!=0 && (doagain&&vv!=0))
  583.             break;
  584.         /* Oops.. added this minor cockup fix 1.11 */
  585.         if(vb!=0 && !doagain && fl== 0)
  586.             break;
  587.         nv=vv%150;
  588.         vv/=150;
  589.         if((vv==vb)||(doagain&&Actions[ct].Vocab==0))
  590.         {
  591.             if((vv==0 && RandomPercent(nv))||doagain||
  592.                 (vv!=0 && (nv==no||nv==0)))
  593.             {
  594.                 int f2;
  595.                 if(fl== -1)
  596.                     fl= -2;
  597.                 if((f2=PerformLine(ct))>0)
  598.                 {
  599.                     /* ahah finally figured it out ! */
  600.                     fl=0;
  601.                     if(f2==2)
  602.                         doagain=1;
  603.                     if(vb!=0 && doagain==0)
  604.                         return(0);
  605.                 }
  606.             }
  607.         }
  608.         ct++;
  609.         if(Actions[ct].Vocab!=0)
  610.             doagain=0;
  611.     }
  612.     if(fl!=0 && disable_sysfunc==0)
  613.     {
  614.         int i;
  615.         if(Items[LIGHT_SOURCE].Location==MyLoc ||
  616.            Items[LIGHT_SOURCE].Location==CARRIED)
  617.             d=0;
  618.         if(vb==10 || vb==18)
  619.         {
  620.             /* Yes they really _are_ hardcoded values */
  621.             if(vb==10)// prendi
  622.             {
  623.                 if(stricmp(NounText,"TUTTO")==0)
  624.                 {
  625.                     int ct=0;
  626.                     int f=0;
  627.  
  628.                     if(d) {
  629.                         OutputScott("E' buio.\n");
  630.                         Speak("E' buio.");
  631.                         return 0;
  632.                     }
  633.                     while(ct<=GameHeader.NumItems)
  634.                     {
  635.                         if(Items[ct].Location==MyLoc && Items[ct].AutoGet!=NULL && Items[ct].AutoGet[0]!='*')
  636.                         {
  637.                             no=WhichWord(Items[ct].AutoGet,Nouns);
  638.                             disable_sysfunc=1;  /* Don't recurse into auto get ! */
  639.                             PerformActions(vb,no);  /* Recursively check each items table code */
  640.                             disable_sysfunc=0;
  641.                             if(CountCarried()==GameHeader.MaxCarry)
  642.                             {
  643.                                 if(Options&YOUARE) {
  644.                                     OutputScott("Stai portando troppe cose.\n");
  645.                                     Speak("Stai portando troppe cose.");
  646.                                 }
  647.                                 else {
  648.                                     OutputScott("Sto portando troppe cose.\n");
  649.                                     Speak("Sto portando troppe cose.");
  650.                                 }
  651.                                 return(0);
  652.                             }
  653.                             Items[ct].Location= CARRIED;
  654.                             Redraw=1;
  655.                             OutBuf(Items[ct].Text);
  656.                             Speak(Items[ct].Text);
  657.                             OutputScott(": O.K.\n");
  658.                             Speak("O.K.");
  659.                             f=1;
  660.                         }
  661.                         ct++;
  662.                     }
  663.                     if(f==0) {
  664.                         OutputScott("Non c'e' nulla da prendere.\n");
  665.                         Speak("Non c'e' nulla da prendere.");
  666.                     }
  667.                     return(0);
  668.                 }
  669.                 if(no==-1)
  670.                 {
  671.                     OutputScott("Prendo cosa ?\n");
  672.                     Speak("Prendo cosa ?");
  673.                     return(0);
  674.                 }
  675.                 if(CountCarried()==GameHeader.MaxCarry)
  676.                 {
  677.                     if(Options&YOUARE) {
  678.                         OutputScott("Stai portando troppe cose\n");
  679.                         Speak("Stai portando troppe cose.");
  680.                     }
  681.                     else {
  682.                         OutputScott("Sto portando troppe cose.\n");
  683.                         Speak("Sto portando troppe cose.");
  684.                     }
  685.                     return(0);
  686.                 }
  687.                 i=MatchUpItem(NounText,MyLoc);
  688.                 if(i==-1)
  689.                 {
  690.                     if(Options&YOUARE) {
  691.                         OutputScott("Ti e' impossibile fare questo.\n");
  692.                         Speak("Ti e' impossibile fare questo.");
  693.                     }
  694.                     else {
  695.                         OutputScott("Mi e' impossibile fare questo.\n");
  696.                         Speak("Mi e' impossibile fare questo.");
  697.                     }
  698.                     return(0);
  699.                 }
  700.                 Items[i].Location= CARRIED;
  701.                 OutputScott("O.K.\n");
  702.                 Speak("O.K.");
  703.                 Redraw=1;
  704.                 return(0);
  705.             }
  706.             if(vb==18)//posa
  707.             {
  708.                 if(stricmp(NounText,"TUTTO")==0)
  709.                 {
  710.                     int ct=0;
  711.                     int f=0;
  712.                     while(ct<=GameHeader.NumItems)
  713.                     {
  714.                         if(Items[ct].Location==CARRIED && Items[ct].AutoGet && Items[ct].AutoGet[0]!='*')
  715.                         {
  716.                             no=WhichWord(Items[ct].AutoGet,Nouns);
  717.                             disable_sysfunc=1;
  718.                             PerformActions(vb,no);
  719.                             disable_sysfunc=0;
  720.                             Items[ct].Location=MyLoc;
  721.                             OutBuf(Items[ct].Text);
  722.                             Speak(Items[ct].Text);
  723.                             OutputScott(": O.K.\n");
  724.                             Speak("O.K.");
  725.                             Redraw=1;
  726.                             f=1;
  727.                         }
  728.                         ct++;
  729.                     }
  730.                     if(f==0) {
  731.                         OutputScott("Niente da lasciare.\n");
  732.                         Speak("Niente da lasciare.");
  733.                     }
  734.                     return(0);
  735.                 }
  736.                 if(no==-1)
  737.                 {
  738.                     OutputScott("Lascio cosa ?\n");
  739.                     Speak("Lascio cosa ?");
  740.                     return(0);
  741.                 }
  742.                 i=MatchUpItem(NounText,CARRIED);
  743.                 if(i==-1)
  744.                 {
  745.                     if(Options&YOUARE) {
  746.                         OutputScott("E' per te impossibile fare questo.\n");
  747.                         Speak("E' per te impossibile fare questo.");
  748.                     }
  749.                     else {
  750.                         OutputScott("E' per me impossibile fare questo.\n");
  751.                         Speak("E' per me impossibile fare questo.");
  752.                     }
  753.                     return(0);
  754.                 }
  755.                 Items[i].Location=MyLoc;
  756.                 OutputScott("O.K.\n");
  757.                 Speak("O.K.");
  758.                 Redraw=1;
  759.                 return(0);
  760.             }
  761.         }
  762.     }
  763.     return(fl);
  764. }
  765.  
  766. void main(int argc, char *argv[])
  767. {
  768.     //FILE *f;
  769.     int vb,no,i;
  770.     char prog_name[32];
  771.  
  772.     //{ Betori
  773.     for (i=0;i<1024;i++){
  774.          indirizzo_puntatore[i]=NULL;
  775.       }
  776.     contatore=0;
  777.     //}
  778.     strcpy(prog_name,argv[0]);
  779.     while(argv[1])
  780.     {
  781.         if(*argv[1]!='-')
  782.             break;
  783.         switch(argv[1][1])
  784.         {
  785.             case 'y':
  786.                 Options|=YOUARE;
  787.                 break;
  788.             case 'i':
  789.                 Options&=~YOUARE;
  790.                 break;
  791.             case 'd':
  792.                 Options|=DEBUGGING;
  793.                 break;
  794.             case 's':
  795.                 Options|=SCOTTLIGHT;
  796.                 break;
  797.             case 't':
  798.                 Options|=TRS80_STYLE;
  799.                 break;
  800.             case 'p':
  801.                 Options|=PREHISTORIC_LAMP;
  802.                 break;
  803.             case 'h':
  804.             default:
  805.                 fprintf(stderr,"%s: [-h] [-y] [-s] [-i] [-t] [-d] [-p] <gamename> [savedgame].\n",
  806.                         argv[0]);
  807.                 exit(1);
  808.         }
  809.         if(argv[1][2]!=0) {
  810.             fprintf(stderr,"%s: opzione -%c non prende un parametro.\n",argv[0],argv[1][1]);
  811.             exit(1);
  812.         }
  813.         argv++;
  814.         argc--;
  815.     }
  816.  
  817.     //printf("%d, %s, %s, %s\n",argc,argv[0],argv[1],argv[2]);
  818.     if (argc == 0) {
  819.         WBSTART = TRUE;
  820.         WBMessage = (struct WBStartup *) argv;
  821.         Init(WBMessage->sm_ArgList->wa_Name,"","");
  822.     }
  823.     else Init(prog_name,((argc<2)?"":argv[1]),((argc<3)?"":argv[2]));
  824.  
  825.     srand(time(NULL));
  826.     Look();
  827.     while(1)
  828.     {
  829.         if(Redraw!=0)
  830.         {
  831.             Look();
  832.             Redraw=0;
  833.         }
  834.         PerformActions(0,0);
  835.         if(Redraw!=0)
  836.         {
  837.             Look();
  838.             Redraw=0;
  839.         }
  840.         GetInput(&vb,&no);
  841.         switch(PerformActions(vb,no))
  842.         {
  843.             case -1:
  844.                 OutputScott("Non capisco il tuo comando.\n");
  845.                 Speak("Non capisco il tuo comando.");
  846.                 break;
  847.             case -2:
  848.                 OutputScott("Non posso fare questo ancora.\n");
  849.                 Speak("Non posso fare questo ancora.");
  850.                 break;
  851.         }
  852.         /* Brian Howarth games seem to use -1 for forever */
  853.         if(Items[LIGHT_SOURCE].Location/*==-1*/!=DESTROYED && GameHeader.LightTime!= -1)
  854.         {
  855.             GameHeader.LightTime--;
  856.             if(GameHeader.LightTime<1)
  857.             {
  858.                 BitFlags|=(1L<<LIGHTOUTBIT);
  859.                 if(Items[LIGHT_SOURCE].Location==CARRIED ||
  860.                     Items[LIGHT_SOURCE].Location==MyLoc)
  861.                 {
  862.                     if(Options&SCOTTLIGHT) {
  863.                         OutputScott("La luce si estingue !\n");
  864.                         Speak("La luce si estingue !");
  865.                     }
  866.                     else {
  867.                         OutputScott("Non hai piu' luce !\n");
  868.                         Speak("Non hai piu' luce !");
  869.                     }
  870.  
  871.                 }
  872.                 if(Options&PREHISTORIC_LAMP){
  873.                   Items[LIGHT_SOURCE].Location=DESTROYED;
  874.                 }
  875.             }
  876.             else if(GameHeader.LightTime<25)
  877.             {
  878.                 if(Items[LIGHT_SOURCE].Location==CARRIED ||
  879.                     Items[LIGHT_SOURCE].Location==MyLoc)
  880.                 {
  881.  
  882.                     if(Options&SCOTTLIGHT)
  883.                     {
  884.                         OutputScott("La luce si estinguera' in\n");
  885.                         Speak("La luce si estinguera' in ");
  886.                         OutputNumber(GameHeader.LightTime);
  887.                         SpeakNum(GameHeader.LightTime);
  888.                         OutputScott(" mosse. ");
  889.                         Speak(" mosse.");
  890.                     }
  891.                     else
  892.                     {
  893.                         if(GameHeader.LightTime%5==0) {
  894.                             OutputScott("La luce si affievolisce.\n");
  895.                             Speak("La luce si affievolisce.");
  896.                         }
  897.                     }
  898.                 }
  899.             }
  900.         }
  901.     }
  902. }
  903.  
  904.